package cn.elricyu.tt.action.login;

import cn.elricyu.tt.action.base.Action;
import cn.elricyu.tt.bean.Site;
import cn.elricyu.tt.db.bean.LoginAccount;
import cn.elricyu.tt.exception.ActionException;
import cn.elricyu.tt.store.SystemContainer;
import cn.elricyu.tt.util.HttpClientVM;

public abstract class AbstractLoginAction implements Action {
	protected Site site;

	public AbstractLoginAction() {
	}

	public void excute() {
	}

	public abstract LoginAccount login(String entry, String loginId, String password,
			String verifycode) throws ActionException;


	protected LoginAccount getLoginAccount(String openId) {
		LoginAccount loginAccount = SystemContainer.getLoginAccount(LoginAccount
				.getKey(openId));
		if (loginAccount == null) {
			loginAccount = new LoginAccount(openId);
			SystemContainer.storeLoginAccount(loginAccount);
		}
		return loginAccount;
	}

	protected HttpClientVM getHttpClient(String loginId) {
		String key = LoginAccount.getKey(loginId);
		return SystemContainer.getHttpClient(key);
	}
}
